package factory;

/**
 * @Author Zhouchb
 * @Create 2021-12-2021/12/24 :20:02
 * @Description
 */
interface Factory{
    IPhoneProduct createPhone();
    IRouterProduct createRoute();
}
interface IPhoneProduct{
    void call();
    void photograph();
}
interface IRouterProduct{
    void linkWiFi();
}
class xiaomiPhone implements IPhoneProduct{

    @Override
    public void call() {
        System.out.println("我只生成小米手机");
    }

    @Override
    public void photograph() {
        System.out.println("小米手机1亿像素");
    }
}
class HuaWeiPhone implements IPhoneProduct{

    @Override
    public void call() {
        System.out.println("我只生成华为手机");
    }

    @Override
    public void photograph() {
        System.out.println("华为手机能拍照");
    }
}
class XiaomiRouter implements IRouterProduct{

    @Override
    public void linkWiFi() {
        System.out.println("生成小米路由");
    }
}
class HuaweiRouter implements IRouterProduct{

    @Override
    public void linkWiFi() {
        System.out.println("生成华为路由");
    }
}
class XiaomiAbstractFactory implements Factory{

    @Override
    public IPhoneProduct createPhone() {
        return new xiaomiPhone();
    }

    @Override
    public IRouterProduct createRoute() {
        return new XiaomiRouter();
    }
}
class HuaWeiAbstractFactory implements Factory{

    @Override
    public IPhoneProduct createPhone() {
        return new HuaWeiPhone();
    }

    @Override
    public IRouterProduct createRoute() {
        return new HuaweiRouter();
    }
}
public class AbstractFactory {
    public static void main(String[] args) {
        XiaomiAbstractFactory xFactory = new XiaomiAbstractFactory();
        IPhoneProduct phone = xFactory.createPhone();
        IRouterProduct route = xFactory.createRoute();
        phone.call();
        route.linkWiFi();
        HuaWeiAbstractFactory huaWeiAbstractFactory = new HuaWeiAbstractFactory();
        IPhoneProduct phone1 = huaWeiAbstractFactory.createPhone();
        IRouterProduct route1 = huaWeiAbstractFactory.createRoute();
        phone1.call();
        route1.linkWiFi();

    }
}
class ZN{
    public static void main(String[] args) {
        int[] arr = new int[]{8,6,5,7};//8,6,4,2,3,5,7
        int p1=0;
        int p2=0;
        int l=0,r=arr.length-1;
        while (l<=r){
            if (arr[l]>=arr[r]&&l<=r){
                p1+=arr[l];
                l++;
            }else {
                p1+=arr[r];
                r--;
            }
            if (arr[l]>=arr[r]&&l<=r){
                p2+=arr[l];
                l++;
            }else if(l<=r) {
                p2+=arr[r];
                r--;
            }
        }
        System.out.println("p1:"+p1);
        System.out.println("p2:"+p2);
    }
}